package cn.tedu.sp04.order.feign.fb;

import cn.tedu.sp01.pojo.Item;
import cn.tedu.sp04.order.feign.ItemClient;
import cn.tedu.web.util.JsonResult;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

@Component
public class ItemClientFB implements ItemClient {
    @Override
    public JsonResult<List<Item>> getItems(String orderId) {
        if (Math.random()<0.5){
            List<Item> items= Arrays.asList(new Item[]{
               new Item(1,"商品1",2),
               new Item(2,"商品2",3),
               new Item(3,"商品3",4),
               new Item(4,"商品4",5),
               new Item(5,"商品5",6),
            });
            return JsonResult.ok().data(items);
        }
        return JsonResult.err().msg("获取订单的商品列表失败");
    }

    @Override
    public JsonResult decreaseNumber(List<Item> items) {
        return JsonResult.err().msg("减少商品库存失败");
    }
}
